<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <input type="text" v-model="name" />
        <button @click="add">添加</button>
        <ul>
            <li v-for="book in bookList" :key="book.id">
                <div>
                    <input type="checkbox">
                    {{ book.id + '-' + book.name }}
                </div>
            </li>
        </ul>
    </div>
</body>
<script src="vue.js"></script>
<script>
    const app = new Vue({
        el: "#app",
        data: {
            name: "",
            bookList: [
                {
                    id: 1,
                    name: "水浒传"
                },
                {
                    id: 2,
                    name: "西游记"
                },
                {
                    id: 3,
                    name: "红楼梦"
                },
                {
                    id: 4,
                    name: "三国演义"
                }
            ]
        },
        methods: {
            add(){
                this.bookList.unshift({id: this.bookList.length + 1, name: this.name})
            }
        }
    })
</script>
</html>